#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int N = 309; //1e5+5//100005

int stone[N];
int n,tmp;
ll ans;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> stone[i];
	}
	sort(stone+1,stone+1+n);
	if(n%2==0)
		tmp = n/2-1;
	else
		tmp = n/2;
	for(int i=0;i<=tmp;i++)
	{
		ans += (stone[n-i] - stone[i])*(stone[n-i] - stone[i]);
		ans += (stone[n-i] - stone[i+1])*(stone[n-i] - stone[i+1]);
	}
	cout << ans;
	return 0;
}
